package lhb.test.SC.uum.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import lhb.test.SC.common.model.ReturnMessage;
import lhb.test.SC.uum.model.User;

@RestController
public class LoginController {
	
	@RequestMapping("login")
	public Object login(HttpServletRequest request){
		HttpSession session = request.getSession(true);
		User user = new User();
		user.setName("lhb");
		session.setAttribute("user", user);
		System.out.println("登录成功_user:"+user.getName());
		return new ReturnMessage("登录成功");
	}
	
	@RequestMapping("onNoLog")
	public Object onNoLog(HttpServletRequest request){
		return new ReturnMessage("1001","没有登录或已失效，请重新登录");
	}
	
	@RequestMapping("logout")
	public Object logout(HttpServletRequest request){
		HttpSession session = request.getSession();
		session.invalidate();
		return new ReturnMessage("退出成功");
	}
	
}
